<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table{
            width: 500px;
            margin: 100px auto;
            border-collapse: collapse;
            text-align: center;
        }
        td,th{
            border: 1px solid #333;
        }
        thead tr{
            height: 40px;
            background-color: #ccc;
        }
        a{
            text-decoration: none;
        }
    </style>
</head>
<body>
    <table>
        <thead>
            <tr>
                <th>姓名</th>
                <th>科目</th>
                <th>成绩</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            
        </tbody>
    </table>
    <script>
        var datas = [
            {
                name: '谭坤新',
                subject: 'JavaScript',
                score: 100,
            },
            {
                name: '谭坤新',
                subject: 'JavaScript',
                score: 100,
            },
            {
                name: '谭坤新',
                subject: 'JavaScript',
                score: 100,
            },
            {
                name: '谭坤新',
                subject: 'JavaScript',
                score: 100,
            }
        ];
        var tb = document.querySelector('tbody');
        for(var i = 0; i < datas.length; i++){
            var tr = document.createElement('tr');
            tb.appendChild(tr);
            for(var k in datas[i]){
                //创建单元格
                var td = document.createElement('td');
                td.innerHTML = datas[i][k];
                tr.appendChild(td);
            }
            //创建删除单元格
            var td = document.createElement('td');
            td.innerHTML = '<a href="javascript:;">删除</a>';
            tr.appendChild(td);
            var deletes = document.querySelectorAll('a');
            deletes[i].onclick = function(){
                tb.removeChild(this.parentNode.parentNode);
            }
        }

    </script>
</body>
</html>